/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.deployment.manager;

import br.com.deployment.entidade.selo.CorSelo;
import br.com.deployment.message.Msg;
import br.com.deployment.servico.CorSeloServico;
import java.io.IOException;
import java.io.Serializable;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;

/**
 *
 * @author elyjr
 */
@ManagedBean
@SessionScoped
public class ManagerCorSelo implements Serializable {

    @EJB
    CorSeloServico corSeloServico;
    
    private CorSelo corSelo;

    public ManagerCorSelo(){
        clear();
    }
        
    public void clear(){
        corSelo = new CorSelo();
    }

    public void salvar(){
       corSeloServico.salvar(corSelo);
       Msg.messagemInfo("Cor do selo salvo com sucesso.");
       clear();        
    }
     
    public void redirect(String string) {
        try {
            clear();
            FacesContext context = FacesContext.getCurrentInstance();
            context.getExternalContext().redirect(string);
        } catch (IOException ex) {
            Logger.getLogger(ManagerCorSelo.class.getName()).log(Level.SEVERE, null, ex);
        }
    }
    
     public CorSelo getCorSelo() {
        return corSelo;
    }

    public void setCorSelo(CorSelo corSelo) {
        this.corSelo = corSelo;
    }

}
